	<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/tags/trymore" prefix="tm"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix='fmt'%>

<style>
	.tbl td {border-color: #797979}
</style>

<script src="resources/js/jquery/jmainfest/jquery.ui.widget.min.js" type="text/javascript"></script>
<script src="resources/js/jquery/jmainfest/jquery.marcopolo.js" type="text/javascript"></script>
<script src="resources/js/jquery/jmainfest/jquery.manifest.js" type="text/javascript"></script>

<script>
	$(function(){
	
		var current_panel = $.pdialog.getCurrent() && $.pdialog.getCurrent().filter(":visible").length > 0 ? $.pdialog.getCurrent() : navTab.getCurrentPanel();
		
		$('#project_participants', current_panel).manifest({
			// Use each location's full name as the display text.
			formatDisplay: function (data, $item, $mpItem) {
				return data.username;
			},
			// Use each location's ID as the value to be submitted.
			formatValue: function (data, $value, $item, $mpItem) {
				return data.id;
			},
			<logic:present name="projectAttendees">
			values: eval(${projectAttendees}),
			</logic:present>
			valuesName: 'projectAttendeeId',
			<c:choose>
				<c:when test="${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff'}">
					readonly: true,
				</c:when>
				<c:when test="${!(entity.currentProcess eq null && entity.projectStatus eq 1) && sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.id eq entity.projectManager.id}">
					readonly: true,
				</c:when>
				<c:otherwise>
					marcoPolo: {
						url: 'app/base.do?action=lookupUserByName',
						formatItem: function (data) {
						  return '"' + data.username + '" (' + data.userNo + ')';
						},
						param: 'search'
					}
				</c:otherwise>
			</c:choose>
		});
				
		<c:if test="${op eq null}">
		
		$("#dialog_dictIndu").bind("change", function(){
			if ($(this).val() == "") {
				$("#projectNo").val("");
			} else {
				if ($("#projectCreationTime").val() == "") {
					alertMsg.error("请填写`项目登记时间`...");
				} else {
					generic_ajax_op("app/project/checkin.do?action=actionGenerateProjectNo", "{'typeId':'" + this.value + "', 'projectCreationTime':'" + $("#projectCreationTime").val() + "'}", (function(){
						$("#background,#progressBar").show();
					}), (function(rsp_msg){
							if (rsp_msg) {
								var json_obj = eval('(' + rsp_msg + ')');
								if (json_obj.statusCode == 200) {
									$("#projectNo").val(json_obj.projectNo);
								} else {
									alertMsg.error(json_obj.error);
								}
							}
							$("#background,#progressBar").hide();
						})
					);
				}
			}
		});
		
		$("#projectCreationTime").change(function(){
			if ($(this).val() == "") {
				alertMsg.error("请填写`项目登记时间`...");
			} else {
				if ($("#dialog_dictIndu").val() != "") {
					generic_ajax_op("app/project/checkin.do?action=actionGenerateProjectNo", "{'typeId':'" + $("#dialog_dictIndu").val() + "', 'projectCreationTime':'" + $(this).val() + "'}", (function(){
						$("#background,#progressBar").show();
					}), (function(rsp_msg){
							if (rsp_msg) {
								var json_obj = eval('(' + rsp_msg + ')');
								if (json_obj.statusCode == 200) {
									$("#projectNo").val(json_obj.projectNo);
								} else {
									alertMsg.error(json_obj.error);
								}
							}
							$("#background,#progressBar").hide();
						})
					);
				}
			}
		});
		
		</c:if>
		
		$("#projectReferralId").change(function(){
			if ($(this).val() == "-1") {
				$("#projectReferralName").css("display", "");
				$("#projectReferralName").addClass("required");
			} else {
				$("#projectReferralName").css("display", "none");
				$("#projectReferralName").removeClass("required");
				$("#projectReferralName").val("");
			}
		});
	});
</script>

<style>
	#tblexp td.banner {line-height: 35px; font-size: 18px; font-weight: bold; text-align: center; margin: 0;}
	#tblexp td.field {background-color: #CFDBEC; line-height: ${entity ne null && (entity.currentProcess ne null || entity.projectStatus eq 2 || entity.projectStatus eq 3) ? '25px' : '57px'}; text-align: center; margin: 0; width: 100px; font-size: 9pt;}
	#tblexp input.textInput {float:none;margin: 5px; width: 80px; height: 23px;}
	.export_present {display:none;}
	div.mf_container {margin: 5px;}
</style>

<div class="pageFormContent" layoutH="${pid ne null ? (flag ne null ? 58 : 95) : 55}" style="border-top: none; background-color: #FFF">

	<c:if test="${entity eq null}">
	<div align="center" style="line-height: 35px; font-size: 28px; font-weight: bold; margin-bottom: 10px">项目登记表</div>
	</c:if>

	<div id="finaexp_print_wrapper">
		
		<div align="right" style="margin-bottom: 15px; margin-right: 15px;">
			<table cellpadding="0" cellspacing="0" style="border-bottom: 1px solid #999; padding-bottom: 10px;">
				<tr>
					<td width="95px" align="center">项目登记人</td>
					<td>
						<input id="projectRecorderId" name="recorder.id" value="${recordUser ne null ? recordUser.id : ''}" type="hidden"/>
						<input class="required" error_message="请输入`项目登记人`" name="recorder.username" type="text" value="${recordUser ne null ? recordUser.username : ''}" <c:if test="${op eq null || op ne 'view'}">postField="search" suggestFields="username,userNo" suggestUrl="app/base.do?action=lookupUserByName" lookupGroup="recorder"</c:if> style="width: 90%;" ${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? 'readonly' : ''}/>
					</td>
					<td width="95px" align="center">项目登记时间</td>
					<td>
						<input class="required textInput ${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? '' : 'date'}" id="projectCreationTime" name="projectCreationTime" value="<fmt:formatDate value='${recordTime}' type='date' pattern='yyyy-MM-dd'/>" error_message="请填写`项目登记时间`" type="text" style="width: 80px;" ${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? 'readonly' : ''}/>
					</td>
					<td width="95px" align="center">项目可见范围</td>
					<td>
						<select class="combox required" name="projectVisibleRange" id="dialog_PVR">
							<option value="0" ${entity ne null && entity.projectVisibleRange ne null && entity.projectVisibleRange eq 0 ? 'selected="true"' : ''}>公司内部公开</option>
							<option value="1" ${entity ne null && entity.projectVisibleRange ne null && entity.projectVisibleRange eq 1 ? 'selected="true"' : ''}>项目内部公开</option>
							<option value="2" ${entity ne null && entity.projectVisibleRange ne null && entity.projectVisibleRange eq 2 ? 'selected="true"' : ''}>项目高层公开</option>
						</select>
					</td>
				</tr>
			</table>
		</div>
		
		<table class="tbl" id="tblexp" cellpadding="0" cellspacing="0" width="98%" border="1" style="border-collapse: collapse; border-color: #797979; margin: 0 auto;" rules="all">
			<tr>
				<td class='field'>项目编号</td>
				<td>
					<input error_message="`项目编号`已经存在或者为空..." class="textInput ${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? '' : 'required'}" id="projectNo" value="${entity ne null ? entity.projectNo : ''}" name="projectNo" type="text" style="width: 90%;" <c:choose><c:when test="${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff'}">readonly</c:when><c:otherwise>remote="app/project/checkin.do?action=actionUniqueCheckProjectNo&force_ajax&formProjectNo=${entity ne null ? entity.projectNo : ''}"</c:otherwise></c:choose> />
				</td>
				<td class='field'>项目名称</td>
				<td colspan="3">
					<input class="required textInput" error_message="请输入`项目名称`" id="projectName" name="projectName" value="${entity ne null ? entity.projectName : ''}" type="text" style="width: 97%;" ${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? 'readonly' : ''}/>
				</td>
				<td class='field'>所属行业<b style="color: red; margin-left: 4px;">*</b></td>
				<td style="padding-left: 5px;">
					<select class="combox required" error_message="请选择`项目所属行业`" name="projectTypeId" id="dialog_dictIndu">
						<option value="">请选择一个行业</option>
						<logic:present name="dictInds">
							<logic:iterate name="dictInds" id="dict">
								<option value="${dict.id}" ${entity ne null && entity.projectType ne null && entity.projectType.id eq dict.id ? 'selected="true"' : ''}>${dict.dictKey}</option>
							</logic:iterate>
						</logic:present>
					</select>
				</td>
			</tr>
			<tr>
				<td class='field'>项目推荐时间</td>
				<td>
					<input name="projectRecommendedDate" error_message="请输入`项目推荐时间`" class="${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? '' : 'date'} required textInput" value="<fmt:formatDate value='${recommendTime}' type='date' pattern='yyyy-MM-dd'/>" format="yyyy-MM-dd" type="text" style="width: 90%;" ${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? 'readonly' : ''}/>
				</td>
				<td class='field'>项目推荐人</td>
				<td style="${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? '' : 'padding-left: 5px;'}">
					<c:choose>
						<c:when test="${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff'}">
							<input class="" type="text" value="${entity ne null && entity.projectReferralName ne null ? entity.projectReferralName : ''}" readonly />
						</c:when>
						<c:otherwise>
							<div>
								<select class="combox" id="projectReferralId" name="projectReferralId">
									<option value="">请选择项目推荐人</option>
									<logic:present name="users">
										<logic:iterate name="users" id="user">
											<option value="${user.id}" ${entity ne null && entity.projectReferral ne null && entity.projectReferral.id eq user.id ? 'selected' : ''}>${user.username}</option>
										</logic:iterate>
									</logic:present>
									<option value="-1">其他</option>
								</select>
							</div>
							<div>
								<input type="text" error_message="请输入`项目推荐人`" id="projectReferralName" name="projectReferralName" value="" style="display: none; width: 90%; float: left; margin: 0"/>
							</div>
						</c:otherwise>
					</c:choose>
				</td>
				<td class='field'>项目发明人</td>
				<td>
					<input class="" name="projectInventor" type="text" value="${entity ne null && entity.projectInventor ne null ? entity.projectInventor : ''}" style="width: 90%;" />
				</td>
				<td class='field'>发明人联系方式</td>
				<td>
					<input id="projectInventorContact" name="projectInventorContact" value="${entity ne null && entity.projectInventorContact ne null ? entity.projectInventorContact : ''}" type="text" style="width: 90%;" ${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? 'readonly' : ''}/>
				</td>
			</tr>
			<tr>
				<td class='field' <c:if test="${op eq 'allocate' || op eq 'reallocate'}">style="background-color: red;"</c:if>>项目经理</td>
				<td>
					<c:choose>
						<c:when test="${op eq 'edit' && tm:inRange('ROLE_SUPER,ROLE_ADMIN,ROLE_PROJECT_MASTER', sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.roleKey, ',')}">
							<input id="projectManagerId" name="manager.id" value="${entity ne null && entity.projectManager ne null ? entity.projectManager.id : ''}" type="hidden"/>
							<input type="text" name="manager.username" value="${entity ne null && entity.projectManager ne null ? entity.projectManager.username : ''}" style="width: 90%;" readonly />
						</c:when>
						<c:otherwise>
							<input id="projectManagerId" name="manager.id" value="${entity ne null && entity.projectManager ne null ? entity.projectManager.id : ''}" type="hidden"/>
							<input class="${op ne null && op eq 'allocate' ? 'required' : ''}" ${op ne null && op eq 'allocate' ? 'error_message="请输入`项目经理`"' : ''} name="manager.username" type="text" value="${entity ne null && entity.projectManager ne null ? entity.projectManager.username : ''}" <c:if test="${op eq null || op ne 'view'}">postField="search" suggestFields="username,userNo" suggestUrl="app/base.do?action=lookupUserByName" lookupGroup="manager"</c:if> style="width: 90%;" ${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? 'readonly' : ''}/>
						</c:otherwise>
					</c:choose>
				</td>
				<td class='field'>参与人员</td>
				<td colspan="5">
					<input id="project_participants" type="text" name="projectAttendeeIds" style="width: 97%; " 
						value="${entity ne null ? entity.projectAttendeeIds : ''}" ${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' || (!(entity.currentProcess eq null && entity.projectStatus eq 1) && sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.id eq entity.projectManager.id) ? 'readonly' : ''}/>
				</td>
			</tr>
			<tr>
				<td class='field'>合作方类型<b style="color: red; margin-left: 4px;">*</b></td>
				<td style="padding-left: 5px;">
					<select class="combox required" error_message="请选择`合作方类型`" name="projectPartnerId" id="dialog_dictPtn">
						<option value="">请选择合作方类型</option>
						<logic:present name="dictPtns">
							<logic:iterate name="dictPtns" id="dict">
								<option value="${dict.id}" ${entity ne null && entity.projectPartnerType ne null && entity.projectPartnerType.id eq dict.id ? 'selected="true"' : ''}>${dict.dictKey}</option>
							</logic:iterate>
						</logic:present>
					</select>
				</td>
				<td class='field'>合作方名称</td>
				<td>
					<input class="required" id="projectPartnerName" error_message="请选择`合作方名称`"name="projectPartnerName" value="${entity ne null ? entity.projectPartnerName : ''}" type="text" style="width: 90%;" ${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? 'readonly' : ''}/>
				</td>
				<td class='field'>合作方参与人员</td>
				<td colspan="3">
					<input id="project_partnerAttendees" name="projectPartnerAttendeeIds" value="${entity ne null ? entity.projectPartnerAttendeeIds : ''}" type="text" style="width: 95%;" ${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? 'readonly' : ''}/>
				</td>
			</tr>
			<tr>
				<td class='field'>项目摘要</td>
				<td colspan="9">
					<textarea name="projectSummary" rows="2" style="width: 98%; height: ${entity ne null && (entity.currentProcess ne null || entity.projectStatus eq 2 || entity.projectStatus eq 3) ? '60px' : '60px'}; margin: 5px;" ${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? 'readonly' : ''}>${entity ne null ? entity.projectSummary : ''}</textarea>
				</td>
			</tr>
			<tr>
				<td class='field'>备注</td>
				<td colspan="9">
					<textarea name="projectMeto" rows="2" style="width: 98%; height: ${entity ne null && (entity.currentProcess ne null || entity.projectStatus eq 2 || entity.projectStatus eq 3) ? '25px' : '60px'}; margin: 5px;" ${op ne null && op eq 'view' || op eq 'audit' || op eq 'post_stuff' ? 'readonly' : ''}>${entity ne null ? entity.projectMeto : ''}</textarea>
				</td>
			</tr>
			<c:if test="${entity ne null && (entity.currentProcess ne null || entity.projectStatus eq 2 || entity.projectStatus eq 3)}">
			<tr>
				<td class='field' style="background-color:#999" rowspan="${fn:length(entity.processEvents)}">项目进展记录</td>
				<logic:present name="entity" property="processEvents">
					<logic:iterate name="entity" property="processEvents" length="1" id="event">
						<td style="text-align:center;line-height: 25px;background-color:#CCCCCC">${event.eventName}</td>
						<td style="text-align:center"><fmt:formatDate value='${event.eventTime}' type='date' pattern='yyyy-MM-dd HH:mm'/></td>
						<td style="text-align:center">${event.eventOperator ne null ? event.eventOperator.username : '---'}</td>
						<td style="text-align:left; padding-left: 5px;" colspan="4">
							<c:choose>
								<c:when test="${event.eventState ne null}">
									<c:choose>
										<c:when test="${event.eventState ne null && event.eventState eq 1}">通过</c:when>
										<c:when test="${event.eventState ne null && event.eventState eq -1}">退回</c:when>
										<c:when test="${event.eventState ne null && event.eventState eq 0}">否决</c:when>
									</c:choose>
									<c:if test="${event.eventComments ne null && event.eventComments ne ''}"> (审核意见：${event.eventComments})</c:if>
								</c:when>
								<c:otherwise>
									<c:if test="${event.eventComments ne ''}"> ${event.eventComments}</c:if>
								</c:otherwise>
							</c:choose>
						</td>
					</logic:iterate>
				</logic:present>
			</tr>
			<logic:present name="entity" property="processEvents">
				<logic:iterate name="entity" property="processEvents" id="event" offset="1">
					<tr>
						<td style="text-align:center;line-height: 25px;background-color:#CCCCCC">${event.eventName}</td>
						<td style="text-align:center"><fmt:formatDate value='${event.eventTime}' type='date' pattern='yyyy-MM-dd HH:mm'/></td>
						<td style="text-align:center">${event.eventOperator ne null ? event.eventOperator.username : '---'}</td>
						<td style="text-align:left; padding-left: 5px;" colspan="4">
							<c:choose>
								<c:when test="${event.eventState ne null}">
									<c:choose>
										<c:when test="${event.eventState ne null && event.eventState eq 1}">
											通过<c:if test="${event.eventComments ne null && event.eventComments ne ''}"> (审核意见：${event.eventComments})</c:if></c:when>
										<c:when test="${event.eventState ne null && event.eventState eq -1}">
											<c:if test="${event.eventComments ne null && event.eventComments ne ''}"> ${event.eventComments}</c:if></c:when>
										<c:when test="${event.eventState ne null && event.eventState eq 0}">
											否决<c:if test="${event.eventComments ne null && event.eventComments ne ''}"> (审核意见：${event.eventComments})</c:if></c:when>
									</c:choose>
								</c:when>
								<c:otherwise>
									<c:if test="${event.eventComments ne ''}"> ${event.eventComments}</c:if>
								</c:otherwise>
							</c:choose>
						</td>
					</tr>
				</logic:iterate>
			</logic:present>
			<tr>
				<td class='field' style="background-color:#FF9900" rowspan="${fn:length(entity.processForms) + 1}">项目流程</td>
				<td style="text-align:center;line-height: 25px;background-color:#FFFF00">项目进展环节</td>
				<td style="text-align:center;line-height: 25px;background-color:#FFFF00">操作时间</td>
				<td style="text-align:center;line-height: 25px;background-color:#FFFF00">操作人</td>
				<td style="text-align:center;line-height: 25px;background-color:#FFFF00" colspan="4">操作描述</td>
			</tr>
			<logic:present name="entity" property="processForms">
				<logic:iterate name="entity" property="processForms" id="form">
					<tr style="background-color:${entity.currentProcess ne null && entity.currentProcess.id eq form.id ? '#FF9900' : (form.auditState ne null ? (form.auditState eq 1 ? '#A5E277' : '#DCDCDC') : '#FFF')}">
						<td style="text-align:center; line-height: 25px;">${form.nodeTitle}</td>
						<td style="text-align:center;"><fmt:formatDate value='${form.auditDate}' type='date' pattern='yyyy-MM-dd HH:mm'/></td>
						<td style="text-align:center;">${form.auditor ne null ? form.auditor.username : '---'}</td>
						<td style="text-align:left; padding-left: 5px;" colspan="4">
							<c:choose>
								<c:when test="${form.auditState ne null && form.auditState eq 1}">同意${form.nodeTitle}</c:when>
								<c:when test="${form.auditState ne null && form.auditState eq -1}">退回${form.nodeTitle}</c:when>
								<c:when test="${form.auditState ne null && form.auditState eq 0}">否决${form.nodeTitle}</c:when>
								<c:when test="${form.auditState ne null && form.auditState eq -2}">该审核流程已被跳跃...</c:when>
							</c:choose>
							<c:if test="${form.auditComments ne null && form.auditComments ne ''}"> (审核意见：${form.auditComments})</c:if>
						</td>
					</tr>
				</logic:iterate>
			</logic:present>
			</c:if>
		</table>
	</div>
	
	<c:if test="${entity eq null}">
	<div align="right" style="line-height: 25px; margin: 10px 0; color: #999">
		项目登记过程中, 倘若未指定项目经理, 系统则默认将项目登记人设置成项目经理, 直到项目部长进行分配操作后生效..
	</div>
	</c:if>
	
	<input type="hidden" name="id" value="${entity ne null ? entity.id : -1}" />
	<input type="hidden" name="op" value="${op ne null ? op : ''}" />
	
	<c:if test="${optype ne null}">
	<input type="hidden" name="optype" value="${optype ne null ? optype : ''}" />
	</c:if>
	
</div>
